package com.tedu;

import java.util.Random;

//创建随机数
public class Test006 {
    public static void main (String[] args) {
        Random random = new Random();

        //动态创建一个数组 长度为5  利用 for循环  随机数 赋值

        int[] a = new int[5];
        for (int i = 0; i < a.length; i++) {
            int i1 = random.nextInt(100);
            a[i] = i1;
        }

        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

        //求出  最大值  ,   最小值
        int max = 0;
        int min = a[0];//  5  90 1 2 4
        for (int i = 0; i < a.length; i++) {
            if (max < a[i]) {
                max = a[i];
            }
            if (a[i] < min) {
                min = a[i];
            }
        }

        System.out.println("max = " + max);
        System.out.println("min = " + min);
    }
}
